<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
    <meta charset="UTF-8">
    <title>Login</title>
    <link rel="stylesheet" type="text/css" href="Login.css"/>
    <script type="application/javascript" src="http://code.jquery.com/jquery-1.10.0.js"></script>
    <style type="text/css">
        html{
            width: 100%;
            height: 100%;
            overflow: hidden;
            font-style: sans-serif;
        }
        body{
            width: 100%;
            height: 100%;
            font-family: 'Open Sans',sans-serif;
            margin: 0;
            background-color: #4A374A;
        }
        #login{
            position: absolute;
            top: 50%;
            left:50%;
            margin: -150px 0 0 -150px;
            width: 300px;
            height: 300px;
        }
        #login h1{
            color: #fff;
            text-shadow:0 0 10px;
            letter-spacing: 1px;
            text-align: center;
        }
        h1{
            font-size: 2em;
            margin: 0.67em 0;
        }
        input{
            width: 278px;
            height: 29px;
            margin-bottom: 25px;
            outline: none;
            padding: 10px;
            font-size: 13px;
            color: #fff;
            text-shadow:1px 1px 1px;
            border-top: 1px solid #312E3D;
            border-left: 1px solid #312E3D;
            border-right: 1px solid #312E3D;
            border-bottom: 1px solid #56536A;
            border-radius: 14px;
            background-color: #2D2D3F;
        }
        .but{
            width: 300px;
            min-height: 20px;
            display: block;
            background-color: #4a77d4;
            border: 1px solid #3762bc;
            color: #fff;
            padding: 9px 14px;
            font-size: 15px;
            line-height: normal;
            border-radius: 5px;
            margin: 0;
        }

    </style>
</head>
<body>
<div id="login">
    <h1>Login</h1>
    <form action="/admin/auth/login" id="loginForm" class="fh5co-form animate-box" onsubmit="return false" method="post"
          data-animate-effect="fadeInLeft">
        <div class="form-group">
            <label for="username" class="sr-only">用户名</label>
            <input type="text" class="form-control" id="username" name="username" placeholder="username"
                   autocomplete="off">
        </div>
        <div class="form-group">
            <label for="password" class="sr-only">密码</label>
            <input type="password" class="form-control" id="password" name="password" placeholder="password"
                   autocomplete="off">
        </div>
      <!--  <div class="form-group">
            <label for="remember"><input type="checkbox" id="remember"> Remember Me</label>
        </div>-->
       <!-- <div class="form-group">
            <p>Not registered? <a href="sign-up2.html">Sign Up</a> | <a href="forgot2.html">Forgot Password?</a>
            </p>
        </div>-->
        <div class="form-group">
            <input type="submit" onclick="login()"  value="登录" class="btn btn-primary">
        </div>
    </form>

</div>
</body>

<script  type="text/javascript" >
 /*   $(document).onclick(function(){
        $(".comment").onclick(function(){
            parArr = {};
            var username = $('input[name=username]').val().replace(/(^\s*)|(\s*$)/g, "");
            parArr.username = username;
            var password = $('input[name=password]').val().replace(/(^\s*)|(\s*$)/g, "");
            parArr.username = password;
            var params = JSON.stringify(parArr);
            alert(params);
        });
    });*/


    function login() {
        var username = document.getElementById("username").value;
        var password = document.getElementById("password").value;
        $.ajax({
            type: "POST",
            dataType: "json",
            url: '/admin/auth/login',
            contentType: "application/json",
            data: JSON.stringify({
                "username": username,
                "password": password
            }),
            success: function (result) {
                if (username == ""  || username == null){
                    alert("用户名不能为空")
                }else if (password == "" || password == null){
                    alert("密码不能为空")
                }else {
                    window.location.href = "../goods/list";
                }




                //    window.location.href = "../goods/list";


            }
        });
    }
</script>
</html>